package com.wwwarehouse.taskcenter.constant.job_point;

import com.wwwarehouse.common.common.Common;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by Jackie on 2017/11/1.
 * 保存值
 */

public class TaskCenterCommon {
    private static TaskCenterCommon instance;

    // 获取单例
    public static TaskCenterCommon getInstance() {
        if (instance == null) {
            synchronized (Common.class) {
                if (instance == null) {
                    instance = new TaskCenterCommon();
                }
            }
        }

        return instance;
    }

    private boolean isStart;    // true 开始 false 结束
    private boolean isDetails;  //详情

    private Map startMap;
    private Map endMap;

    public boolean isStart() {
        return isStart;
    }

    public void setStart(boolean start) {
        isStart = start;
    }

    public boolean isDetails() {
        return isDetails;
    }

    public void setDetails(boolean details) {
        isDetails = details;
    }

    public Map<String, Object> getStartMap() {
        return startMap;
    }

    public void setStartMap(Map startMap) {
        this.startMap = startMap;
    }

    public Map<String, Object> getEndMap() {
        return endMap;
    }

    public void setEndMap(Map endMap) {
        this.endMap = endMap;
    }

    public List<TaskCenterBean> parseStartMap() {
        List<TaskCenterBean> list = new ArrayList<>();

        List<Map<String, String>> listMap = (List<Map<String, String>>) startMap.get("list");

        if (listMap != null) {
            for (Map<String, String> map : listMap) {
                TaskCenterBean taskCenterBean = new TaskCenterBean();
                taskCenterBean.setKey(map.get("key"));
                taskCenterBean.setValue(map.get("value"));

                list.add(taskCenterBean);
            }
        }

        return list;
    }

    public List<TaskCenterBean> parseEndMap() {
        List<TaskCenterBean> list = new ArrayList<>();

        List<Map<String, String>> listMap = (List<Map<String, String>>) endMap.get("list");

        if (listMap != null) {
            for (Map<String, String> map : listMap) {
                TaskCenterBean taskCenterBean = new TaskCenterBean();
                taskCenterBean.setKey(map.get("key"));
                taskCenterBean.setValue(map.get("value"));

                list.add(taskCenterBean);
            }
        }

        return list;
    }

    public class TaskCenterBean {
        private String key;
        private String value;

        public String getKey() {
            return key;
        }

        public void setKey(String key) {
            this.key = key;
        }

        public String getValue() {
            return value;
        }

        public void setValue(String value) {
            this.value = value;
        }
    }
}
